package cn.cs.service;

import cn.cs.mapper.AdBannerMapper;
import cn.cs.mapper.UserAddressMapper;
import cn.cs.pojo.AdBanner;
import cn.cs.pojo.UserAddress;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class AdBannerService {

    @Resource
    private AdBannerMapper adBannerMapper;

    @RequestMapping(value = "/getAdbannerById", method = RequestMethod.POST)
    @Transactional
    public AdBanner getAdbannerById(@RequestParam("id") String id) throws Exception{
        return adBannerMapper.getAdbannerById(id);
    }

    @RequestMapping(value = "/getAdbannerListByMap", method = RequestMethod.POST)
    @Transactional
    public List<AdBanner> getAdbannerListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return adBannerMapper.getAdbannerListByMap(param);
    }

    @RequestMapping(value = "/getAdbannerCountByMap", method = RequestMethod.POST)
    @Transactional
    public Integer getAdbannerCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return adBannerMapper.getAdbannerCountByMap(param);
    }

    @RequestMapping(value = "/addAdbanner", method = RequestMethod.POST)
    @Transactional
    public Integer addAdbanner(@RequestBody AdBanner adbanner) throws Exception{
        return adBannerMapper.insertAdbanner(adbanner);
    }

    @RequestMapping(value = "/modifyAdbanner", method = RequestMethod.POST)
    @Transactional
    public Integer modifyAdbanner(@RequestBody AdBanner adbanner) throws Exception{
        return adBannerMapper.updateAdbanner(adbanner);
    }

    @RequestMapping(value = "/deleteAdbannerById", method = RequestMethod.POST)
    @Transactional
    public Integer deleteAdbannerById(@RequestParam("id") String id) throws Exception{
        return adBannerMapper.deleteAdbannerById(id);
    }
    @RequestMapping(value = "/getAllAdBanners", method = RequestMethod.POST)
    @Transactional
    public List<AdBanner> getAllAdBanners(@RequestParam("type")String type) {
        return adBannerMapper.getAllAdBanners(type);
    }



}
